<?php

namespace App\Http\Middleware;

use Closure;

class CheckLogin
{
    /**
     * Handle an incoming request.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \Closure  $next
     * @return mixed
     */
    public function handle($request, Closure $next)
    {
        $id = $request->session()->get('id');
//        $request->session()->flush();
        if (!$id) {
            return response()->json([
                'code'  => 201,
                'msg'  => '用户未登录'
            ]);
        }
        return $next($request);
    }
}
